<?php
	session_start(); //开启session
	if(isset($_SESSION['users'])){

		header('location:./index.php?param=middle');
	}
?>
<!DOCTYPE html>
<html>
<head>
	<title>登陆页面&nbsp-&nbsp后台管理系统</title>
	<link rel="stylesheet" type="text/css" href="./public/css/base.css">
	<link rel="stylesheet" type="text/css" href="./public/css/loginA.css">
	<link rel="stylesheet" type="text/css" href="./public/css/UI.css">
	<script src="./public/js/ajax.js" type="text/javascript"></script>
	<script src="./public/js/parsingMethod.js" type="text/javascript"></script>
	<script src="./public/js/UI.js" type="text/javascript"></script>
</head>
<body>
	<div class="loginA">
		<div class="loginA_title"><span>后台管理系统</span></div>
		<div class="loginA_middle">
			<p><lable>用户名：</lable><input class="users" type="text" name="users"></p>
			<p><lable>密&nbsp&nbsp&nbsp码：</lable><input class="pass" type="password" name="pass"></p>
			<p><lable>验证码：</lable><input class="overy" type="text" name="overy"><img id="myImg" src="./public/packfunc/overyCode.php" onclick="return document.getElementById('myImg').src='./public/packfunc/overyCode.php?r='+ Math.random();"></p>
			<p><input id="btn" type="submit" value="登陆"></p>
		</div>
	</div>
</body>
</html>
<script type="text/javascript">
	var btn = document.getElementById('btn');

	btn.onclick = loginCase;

	function loginCase(){
		// 获取参数
		var users = document.getElementsByClassName('users')[0];
		var pass  = document.getElementsByClassName('pass')[0];
		var overy = document.getElementsByClassName('overy')[0];

		ajax.post("./pose/loginA_action.php", {'users':users.value, 'pass':pass.value, 'overy':overy.value}, function(res){

			if(res.overy === '0'){

				if(res.code === '1'){

					UI.hintDeter({"url":"./index.php?param=middle", "text":"恭喜您，登陆成功！", "icon":"ok"});
				}else{
					UI.hint({"text":"用户名或密码有误！", "load":"1"});
				}
			}else{
				UI.hint({"text":"验证码有误！", "load":"1"});
			}

		}, 'json');
	}
</script>